﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using PassportsModel;
using TestClient.Proxy;
using NeuronESBAccess;

using Channels = System.ServiceModel.Channels;

namespace TestClient
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();

            txtExecuteTime.Enabled = false;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            PassportRequest passportRequest = CreateRequest();

            ApplyServiceClient applyServiceClient = new ApplyServiceClient();

            PassportResponse passportResponse = applyServiceClient.MakePassportRequest(passportRequest);
        }

        private PassportRequest CreateRequest()
        {
            PassportRequest identityRequest = PassportRequest.PassportRequestFactory(eGender.Female, eGender.Female);

            identityRequest.PersonDetails.BirthDate = DateTime.ParseExact("1950/12/31", "yyyy/MM/dd", System.Globalization.CultureInfo.CurrentCulture);
           
            identityRequest.PersonDetails.FamilyName = "Wilberforce";
            identityRequest.PersonDetails.GivenNames = "Wilber";

            identityRequest.PassportType = ePassportType.Adult;
            identityRequest.PassportTravellerType = ePassportTravellerType.Ordinary;
            
            return (identityRequest);
            
        }

        private void button2_Click(object sender, EventArgs e)
        {
             PassportRequest passportRequest = CreateRequest();

             //Channels.Message reply = NeuronClient.ClientTSendRequestByServiceName(passportRequest);
        }

        private void button3_Click(object sender, EventArgs e)
        {
            PassportRequest passportRequest = CreateRequest();

            ApplyServiceClient applyServiceClient = new ApplyServiceClient();

            DateTime start = DateTime.Now;

            for (int i = 0; i < 100; i++)
            {
                PassportResponse passportResponse = applyServiceClient.MakePassportRequest(passportRequest);
            }

            DateTime finish = DateTime.Now;


            TimeSpan span = finish.Subtract(start);


            txtExecuteTime.Text = span.Seconds.ToString();


            //TimeSpan timespan = TimeSpan.Compare(

        }

        private void button4_Click(object sender, EventArgs e)
        {
            PassportRequest passportRequest = CreateRequest();

            ApplyServiceClient applyServiceClient = new ApplyServiceClient();

            PassportResponse passportResponse = applyServiceClient.MakePassportRequest(passportRequest);

        }
    }
}
